package com.spic.business.mountguard.controller;

import com.spic.business.mountguard.domain.QrcodeDate;
import com.spic.business.mountguard.service.IQrcodeDateService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * qrcode二维码写入Controller
 *
 * @author spic
 * @date 2021-11-02
 */
@RestController
@RequestMapping("/mountguard/qrcode")
public class QrcodeDateController extends BaseController
{
    @Autowired
    private IQrcodeDateService qrcodeDateService;

    /**
     * 查询qrcode二维码写入列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:list")
    @GetMapping("/list")
    public TableDataInfo list(QrcodeDate qrcodeDate)
    {
        startPage();
        List<QrcodeDate> list = qrcodeDateService.selectQrcodeDateList(qrcodeDate);
        return getDataTable(list);
    }
    /**
     * 导出qrcode二维码写入列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:export")
    @Log(title = "qrcode二维码写入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QrcodeDate qrcodeDate) throws IOException
    {
        List<QrcodeDate> list = qrcodeDateService.selectQrcodeDateList(qrcodeDate);
        ExcelUtil<QrcodeDate> util = new ExcelUtil<QrcodeDate>(QrcodeDate.class);
        util.exportExcel(response, list, "qrcode二维码写入数据");
    }

    /**
     * 获取qrcode二维码写入详细信息
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qrcodeDateService.selectQrcodeDateById(id));
    }

    /**
     * 新增qrcode二维码写入
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:add")
    @Log(title = "qrcode二维码写入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QrcodeDate qrcodeDate)
    {
        return toAjax(qrcodeDateService.insertQrcodeDate(qrcodeDate));
    }

    /**
     * 修改qrcode二维码写入
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:edit")
    @Log(title = "qrcode二维码写入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QrcodeDate qrcodeDate)
    {
        return toAjax(qrcodeDateService.updateQrcodeDate(qrcodeDate));
    }

    /**
     * 删除qrcode二维码写入
     */
    @PreAuthorize(hasPermi = "business/mountguard:qrcode:remove")
    @Log(title = "qrcode二维码写入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qrcodeDateService.deleteQrcodeDateByIds(ids));
    }
}
